//
// Created by 吴喆 on 2020/3/5.
//

#include "Game.h"

Game *DemoGame::game = new DemoGame();/*NOLINT*/

DemoGame::DemoGame() {
    scenes = std::map<std::string, Scene *>();
}

void DemoGame::init() {
    // 从dir预加载加载texture
    ResourceManager::loadTextureFromDir();

    // 加载着色器
    ResourceManager::loadShader("../shaders/test-shader-v.glsl",
                                "../shaders/test-shader-f.glsl", nullptr, "test");

    ResourceManager::loadShader("../shaders/particle-shader-v.glsl",
                                "../shaders/particle-shader-f.glsl", nullptr, "particle");// 加载着色器

    ResourceManager::loadShader("../shaders/text-shader-v.glsl",
                                "../shaders/text-shader-f.glsl", nullptr, "text");

    auto *firstScene = new DemoScene();
    currentScene = "demo";
    scenes[currentScene] = firstScene;
}

void DemoGame::update() {
    scenes[currentScene]->update();
}

void DemoGame::render() {
    renderScene();
}

void DemoGame::renderScene() {
    scenes[currentScene]->render();
}
